const { createOpenAPI, createWebsocket } = require('qq-guild-bot');
const Spark = require('./Spark');
const Genshin = require('./genshin')
const cp = require('child_process');
const os = require('os');
const fs = require('fs');
const iconv = require('iconv-lite');

class QQBot{
  constructor(QQBotConfig, dbContext, dbMember){
    this.SPARKVER = 1;
    this.enable = true;
    this.Config = QQBotConfig;
    this.client = createOpenAPI(this.Config);
    this.dbContext = dbContext;
    this.dbMember = dbMember;
    this.genshin = new Genshin(dbMember);
    this.BOTID = "12860708407216385564";
    this.Token = Object.values(JSON.parse(fs.readFileSync('./res/JSON/Token.json', 'utf8')));
    this.help = `你好：
  芝士基于官方SDK的QQ频道只因器人!可以调用SparkAPI与您激情对线!
  通用指令：
    1. /help或/帮助—查看本帮助
    2. /ping或/我测—查看哥们的状态
    3. /sign或/签到—签到爆哥们金币
    4. /reset或/布道—让Spark忘了你
    5. /info或/我的—查看自己的信息
    6. /token或/余量—还剩多少token
    78910JQK顺子
    114514./���—神秘功能ᕕ(◠ڼ◠)ᕗ
  后续功能gitee同步激情开发中!
  Star enricliu/qqbot-spark/ 谢谢喵!`
  };
  // get client() { return createOpenAPI(this.Config) };
  get ws() { return createWebsocket(this.Config)};

  async Init(guildID){
    try{
      this.genshin.Init(await this.MemberInit(this.dbMember, guildID));
    }catch(err){console.log(err)};
  };

  async Reply(Msg, SparkConfig){
    if(this.enable){
      try{
        let MsgProcessed = await this.Process(await this.Parse(Msg), SparkConfig)
                                     .catch(err=>console.log(err));
        if (MsgProcessed === null){
          console.log("[INFO]   QQBotReplyNull");
          return;
        }else return await this.SendPlainMsg(MsgProcessed).catch(err=>console.log(err));
      }catch(err){
        console.log(err);
      };
    };
  };

  async Parse(Msg){
    let MsgParsed = {
      msg_type: 0,
      author: {
        id: '',
        username: '',
        sparkVer: 3,
      },
      msg_id: '',
      content: '',
      channelID: '',
      guildID: '',
      time: Date.now()
    };// 接受消息的主要信息
    if(Msg.eventType === 'MESSAGE_CREATE'){
      if        ('content' in Msg.msg){
        await this.dbMember.findOne({userID: Msg.msg.author.id}, (err, data)=>{
          MsgParsed.author.sparkVer = data.sparkVer;
        });
        MsgParsed.msg_type = 'TEXT';// 是文本
        MsgParsed.author.id = Msg.msg.author.id;
        MsgParsed.author.username = Msg.msg.author.username;
        MsgParsed.content = this.EmojiTrans(Msg.msg.content);
        MsgParsed.msg_id = Msg.msg.id;
        MsgParsed.channelID = Msg.msg.channel_id;
        MsgParsed.guildID = Msg.msg.guild_id;
      }
      else if   ('attachments' in Msg.msg){
        MsgParsed.msg_type = 'MEDIA';// 是媒体
        MsgParsed.author.id = Msg.msg.author.id;
        MsgParsed.author.username = Msg.msg.author.username;
        MsgParsed.content = Msg.msg.attachments.url;
        MsgParsed.msg_id = Msg.msg.id;
        MsgParsed.channelID = Msg.msg.channel_id;
        MsgParsed.guildID = Msg.msg.guild_id;
      };
    };// 发来了一条消息
    if(Msg.eventType === 'MESSAGE_DELETE'){
      MsgParsed.msg_type = 'RECALL';// 很快的撤
      MsgParsed.author.id = Msg.msg.message.author.id;
      MsgParsed.author.username = Msg.msg.message.author.username; 
      MsgParsed.msg_id = Msg.msg.message.id;
      MsgParsed.channelID = Msg.msg.message.channel_id;
      MsgParsed.guildID = Msg.msg.message.guild_id;
    };// 撤回了一条消息
    return MsgParsed;
  };// 分析得收到的消息return MsgParsed(JSON: author, content, msg_id, msg_type, time)
  
  async Process(MsgParsed, SparkConfig){
    let MsgProcessed = MsgParsed;
    let Content = '';
    try {
      switch(MsgParsed.msg_type){
        case 'TEXT':
          if (MsgParsed.content.substring(0, 3) == "<@!"){
            if(MsgParsed.content.substring(0, 25) !== `<@!${this.BOTID}> `) return null;
            else MsgParsed.content = MsgParsed.content.slice(25);
          };
          if (MsgParsed.content.charAt(0) == '/') Content = await this.Command(MsgParsed, SparkConfig);
          else{ 
            MsgProcessed.role = "spark";
            let MsgText = await this.DBContextGetByMsgParsed(MsgParsed);
            let spark = new Spark(SparkConfig, this.dbContext, MsgParsed.author.sparkVer);
            if(typeof MsgText === 'number'){
              Content = "记忆错乱了捏<emoji:34>\n已自动重置上下文(。_。);";
              this.Cmd.reset(MsgParsed);
            } else if(JSON.stringify(MsgText).length >= 8192)
              { Content = "上下文消息太长了!\n请使用 /Reset 或 /布道 重置捏" }
            else {
              let TokenConsumed = 0;
              await spark.GetReply(MsgText).then(
                data =>{
                  if (typeof data === 'string') Content = data;
                  else if (typeof data === 'object') {
                    TokenConsumed = data.token;
                    this.DBContextInsert('user', MsgParsed);
                    this.TokenMannager(TokenConsumed, MsgParsed.author.sparkVer);
                    MsgParsed.content = data.content;
                    MsgParsed.time += 0.5;
                    this.DBContextInsert('assistant', MsgParsed);
                    Content = data.content
                              + `\n\n——回复来自[SparkV${MsgParsed.author.sparkVer}]`
                              + `\n消耗${TokenConsumed}token 剩余${this.Token[MsgParsed.author.sparkVer - 1]}token.`; 
                  }else {
                    Content = "出错了捏(。_。);";
                    console.log('[ERROR]  SparkResolveTypeERR: ' + typeof data);
                  }
                }
              );
            };
          };
          break;
        case 'MEDIA':  Content = "看不懂捏(。_。);"; break;
        case 'RECALL': Content = "怎么撤了(｀へ´)?"; break;
        default: 
          console.log('[ERROR]  ProcessMsgTypeERR: ' + MsgParsed.msg_type); 
          Content = "工口发生Σ( ° △ °|||)︴";
          break;
      };

      delete MsgProcessed.msg_type;
      MsgProcessed.content = Content;

      return MsgProcessed;
    } catch (err) {
      console.log('[ERROR]  QQbotProcessERR: ' + err);
    };
  };// 根据content判断调用 return MsgProcessed(JSON: author, content, msg_id)

  async SendPlainMsg(MsgProcessed){
    try{
      let role = undefined;
      if("role" in MsgProcessed) role = MsgProcessed.role + ":\n";
      let Msg = {
        content: `@${MsgProcessed.author.username} ${role ?? ""} ${MsgProcessed.content}`,
        msg_id: MsgProcessed.msg_id,// 回复msg id
        message_reference: {
          message_id: MsgProcessed.msg_id, 
          ignore_get_message_error: true,
        }
      };
      this.client.messageApi.postMessage(MsgProcessed.channelID, Msg).catch(err=>console.log(err));
      console.log('[QQBot]  ' + MsgProcessed.content);
    } catch (err) {console.log(err)};
  };// 在channelID子频道向author.username发送回复msg_id的内容为content信息

  async SendBottonMsg(MsgProcessed){
    try{
        let { data } = await client.messageApi.postMessage(channelID, {
          markdown: {
            template_id: 1,
            params: [
              {
                key: 'title',
                value: ['标题'],
              },
            ],
          },
          msg_id: MsgProcessed.msg_id,
          keyboard: {
            id: '123',
          },
        });
        console.log(data);
    } catch (err) {console.log(err)};
  }

  
  async Command(cmd, SparkConfig){
    let Content = '';
    if (cmd.content.substring(0, 5) ===  '/qwen'){ Content = await this.Cmd.aliQwen(cmd.content.slice(5))}
    else switch (cmd.content){
      case '/help':  case '/帮助': Content = this.help;                         break;
      case '/ping':  case '/我测': Content = await this.Cmd.ping(SparkConfig);  break;
      case '/sign':  case '/签到': Content = await this.Cmd.sign(cmd);          break;
      case '/info':  case '/我的': Content = await this.Cmd.info(cmd);          break;
      case '/reset': case '/布道': Content = await this.Cmd.reset(cmd);         break;
      case '/token': case '/余量': Content = await this.Cmd.token();            break;
      case '/ver1':  case '/一代': Content = await this.Cmd.ver1(cmd);          break;
      case '/ver2':  case '/二代': Content = await this.Cmd.ver2(cmd);          break;
      case '/ver3':  case '/三代': Content = await this.Cmd.ver3(cmd);          break;
      case '/test': Content = '测试避让已关闭';                                  break;
      case '/ᕕ(◠ڼ◠)ᕗ': case '/ᕙ(◔ᴗ◔)ᕗ': Content = '6';                      break;
      case '/愤怒单抽': case '/1': Content = await this.Cmd.chouka(cmd);         break;
      case '/激爽十连': case '/10': Content = await this.Cmd.chouka10(cmd);      break;
      case '/button': Content = await this.Cmd.button(cmd);                     break;
      default: Content = '指令不对 请不要冒充职业选手<emoji:14>';                 break;
    };
    return Content;
  };
  
  async DBContextInsert(role, MsgParsed){
    let InsertToDB = {
      role:     role,
      userID:   MsgParsed.author.id,      // 用户ID
      content:  MsgParsed.content,
      channelID:MsgParsed.channelID,
      guildID:  MsgParsed.guildID,
      time:     MsgParsed.time,           // 标志位
    };// 新增Context数据库内容
    this.dbContext.insert(InsertToDB, (err)=>{
      if(err) console.log('[ERROR]  DBContextInsertERR:' + err);
      else    console.log(`[DBINFO] DBContext: "${role}"插入成功`);
    });// 内容写入dbContext数据库
  };

  async DBContextGetByMsgParsed(MsgParsed){
    let dbContext = this.dbContext;
    let time = Date.now();
    try{
      let MsgTemp = await new Promise((resolve, reject)=>{
        console.log('[DBINFO] DBContext: 查询上下文');
        dbContext.find({ userID:   MsgParsed.author.id, 
                         guildID:  MsgParsed.guildID, 
                         channelID:MsgParsed.channelID },
        (err, data) => {
          if(err) resolve(-1);
          else if(data == false) resolve([]); // 判断是不是空数组(第一句话)
          else resolve(data);
        });
      });// 读取dbContext
      
      if (MsgTemp === -1) {
        console.log('[DBINFO] DBContext: 失败 读取超时');
        return -1;
      } else {
        console.log('[DBINFO] DBContext: 成功 耗时:' + (Date.now()-time) + 'ms');
        return new Promise((resolve, reject)=>{
          if (MsgTemp == false) {
            if (MsgParsed.content == undefined) resolve("还没有上下文捏\n");
            else resolve([{role: 'user', content: MsgParsed.content}])
          }
          else {  
            let MsgText = [];
            let MsgTempLen = MsgTemp.length;
  
            for(let i = 0; i < MsgTempLen; i++){
              let MsgMin = {time: Infinity};// 最巨大的一集
              for(let j in MsgTemp){ 
                if( MsgMin.time > MsgTemp[j].time ){ 
                  MsgMin.time = MsgTemp[j].time;
                  MsgMin.flag = j;
                };
              };// 从头到尾找一个time最小的MsgTemp，把下标存到MsgMin.flag里
              MsgText.push({
                role:    MsgTemp[MsgMin.flag].role, 
                content: MsgTemp[MsgMin.flag].content
              });// 写入MsgTemp中最早一条的
              MsgTemp.splice(MsgMin.flag, 1);// 删掉此次循环time最小的MsgTemp
            };// 排序，每次取time最小的Msg,push到MsgText
  
            if(MsgParsed.content != undefined) 
              MsgText.push({role: 'user', content: MsgParsed.content});// 最新的userMsg push到MsgText
            //for(let Msg of MsgText) console.log(Msg.role + ": " + Msg.content);// 打印到控制台
            resolve(MsgText);
          };
        });
      };
    }catch(err){
      console.log('[ERROR]  DBContextERR' + err);
    }
  };

  async DBContextDelByMsgParsed(MsgParsed){
    return new Promise((resolve)=>{
      this.dbContext.remove(
        { userID:   MsgParsed.author.id, 
          guildID:  MsgParsed.guildID, 
          channelID:MsgParsed.channelID },
        { multi: true },
        ( err, count ) => {
          if(err) resolve("失败了捏<emoji:34>待会儿再来试试吧");
          else if(count === 0) resolve("归！归,归...额..你好像还没跟我说过话捏");
          else resolve("归零！忘记了" + count + "条记录捏");
        }
      );
    });
  };

  async MemberInit(dbMember, guildID) {
    let userIDs = [];
    let { data } = await this.client.guildApi.guildMembers(guildID,{limit: 1000});
    for (let i of data){
      userIDs.push(i.user.id);
      dbMember.findOne({userID: i.user.id}, (err, userdata)=>{
        if(userdata === null){
          dbMember.insert({
            userID: i.user.id,
            userName: i.user.username,
            sparkVer: this.SPARKVER,
            primoGem: 0,
            latestDate: ""
          });
          console.log(`QQUser:${i.user.id} \t初始化成功`);
        } else if(userdata.userName !== i.user.username){
          dbMember.update({userID: i.user.id}, {$set: {userName: i.user.username}});
          console.log(`QQUser: ${i.user.id} \t用户名更新`);
        } else console.log(`QQUser: ${i.user.id} \t已经存在`);
      });
    };
    return userIDs;
  };

  async TokenMannager(TokenConsumed, SparkVersion){
    if(typeof TokenConsumed !== 'number') console.log("[ERROR]  TokenMannager: Token非数"+ TokenConsumed);
    else {
      if ([1,2,3].includes(SparkVersion)){
        this.Token[SparkVersion - 1] -= TokenConsumed;
        fs.writeFile("./res/JSON/Token.json", JSON.stringify({ v1: this.Token[0], 
                                                    v2: this.Token[1],
                                                    v3: this.Token[2] }),
                                                  err=>{
                                                    if(err) console.log("[ERROR]  TokenMannager: 写入失败")
                                                    else console.log(   "[INFO]   TokenMannager: 写入成功")});
      }else console.log("[ERROR]  TokenMannager: 版本号有误");
    };
    return this.Token;
  };

  Cmd = {
    aliQwen:async function (msg){
      async function writefile(msg){
        return new Promise((resolve, reject)=>{
          let MsgToAliQwen = { role: "user", content: msg };
          fs.writeFile("./res/cache/MsgToAliQwen.json", JSON.stringify(MsgToAliQwen), {encoding: 'utf8'}, (err)=>{ 
            if (err) reject(err);
            else resolve('src\\AliQwen.py');
          });
        });
      };
      async function run(command){
        let platform = os.platform();
        return new Promise((resolve, reject)=>{
          cp.exec((platform == 'win32' ?  command : 'python3 ' + command ), {encoding: 'buffer'}, (err, stdout, stderr)=>{
            if(err){
              console.log('[ERROR]  AliQwen: '+ err);
              resolve("AliQwenERROR");
            }
            let data = JSON.parse((platform == 'win32' ? iconv.decode(stdout, 'cp936') : stdout)).content;
            resolve("通义千问:\n" + data);
          });
        });
      };
      return await run(await writefile(msg));
    }.bind(this),
    ping:   async function (SparkConfig){
        return new Promise((resolve, reject)=>{
          let spark = new Spark(SparkConfig);
          spark.Ping().then((data, err)=>{
            if (err) {
              console.log('[ERROR]  SparkConnectionFailure: '+ err);
              resolve(`Spark连接失败 ERR:${err}`);
            }
            else resolve(`Spark连接成功 延迟${data}ms.`)
        });
        });
    }.bind(this),
    sign:   async function (MsgParsed){
      return this.genshin.signIn(MsgParsed.author.id);
    }.bind(this),
    info:   async function (MsgParsed){
      let content = "\n上下文内容:\n";
      let msgs = await this.DBContextGetByMsgParsed({
        author:   MsgParsed.author, 
        guildID:  MsgParsed.guildID, 
        channelID:MsgParsed.channelID 
      });
      let inventory = await this.genshin.getUserInventory(MsgParsed.author.id);

      if(typeof msgs === "string") content += msgs;
      else for(let msg of msgs) content += `${msg.role}: ${msg.content}\n`;

      content += `库存:\n`;
      for(let item of inventory)
        content += `${item.star}星${item.type == "weapon" ? "武器" : "角色"}"${item.card}": ${item.value}个\n`;
      return content;
    }.bind(this),

    reset:  async function (MsgParsed){
      return await this.DBContextDelByMsgParsed(MsgParsed);
    }.bind(this),

    token:  async function (){
      return `Token状态:\nV1.5剩余${this.Token.v1}\nV2.0剩余${this.Token.v2}\nV3.0剩余${this.Token.v3}`;
    }.bind(this),

    ver1:   async function (MsgParsed){
      await this.dbMember.update({ userID:   MsgParsed.author.id}, {$set: {sparkVer: 1}});
      return "切换到了SparkV1.5哦~"
    }.bind(this),
    ver2:   async function (MsgParsed){
      await this.dbMember.update({ userID:   MsgParsed.author.id}, {$set: {sparkVer: 2}});
      return "切换到了SparkV2.0啦~"
    }.bind(this),
    ver3:   async function (MsgParsed){
      await this.dbMember.update({ userID:   MsgParsed.author.id}, {$set: {sparkVer: 3}});
      return "切换到了SparkV3.0捏~"
    }.bind(this),

    chouka: async function (MsgParsed){
      let data = await this.genshin.diceOnce(MsgParsed.author.id);
      if(typeof data === "number") return `只剩${data}原石了，抽不了了捏`;
      else return `噔噔~ 抽到了${data.star}星"${data.card}"捏\n还剩${data.primoGem}原石!`;
    }.bind(this),
    chouka10: async function (MsgParsed){
      let datas = await this.genshin.diceTenTimes(MsgParsed.author.id);
      let content = "";
      if(typeof datas === "number") content = `只剩${datas}原石了，抽不了了捏`;
      else for(let data of datas.results) content += `\n噔噔~ 抽到了${data.star}星"${data.card}"捏`;
      content += `\n还剩${datas.primoGem}原石!`;

      return content;
    }.bind(this),

    button: async function (MsgParsed){
      this.SendBottonMsg(MsgParsed);
    }.bind(this),
  };

  EmojiTrans(EMJcontent) {
    if ( EMJcontent.indexOf("<emoji:") === -1 ) { return EMJcontent; }
    else{
      let emojiDic = {
        "<emoji:14>":  "(emoji:嘲讽的微笑)",
        "<emoji:1>":   "(emoji:撇嘴)",
        "<emoji:2>":   "(emoji:色)",
        "<emoji:3>":   "(emoji:发呆)",
        "<emoji:4>":   "(emoji:得意)",
        "<emoji:6>":   "(emoji:害羞)",
        "<emoji:7>":   "(emoji:闭嘴)",
        "<emoji:8>":   "(emoji:要睡着了)",
        "<emoji:9>":   "(emoji:撒娇大哭)",
        "<emoji:10>":  "(emoji:尴尬)",
        "<emoji:11>":  "(emoji:愤怒万分)",
        "<emoji:12>":  "(emoji:调戏)",
        "<emoji:13>":  "(emoji:呲牙)",
        "<emoji:0>":   "(emoji:惊讶)",
        "<emoji:15>":  "(emoji:难过)",
        "<emoji:16>":  "(emoji:装酷)",
        "<emoji:96>":  "(emoji:冷汗)",
        "<emoji:18>":  "(emoji:抓狂)",
        "<emoji:19>":  "(emoji:吐了)",
        "<emoji:20>":  "(emoji:偷笑)",
        "<emoji:21>":  "(emoji:可爱)",
        "<emoji:22>":  "(emoji:白眼)",
        "<emoji:23>":  "(emoji:傲慢)",
        "<emoji:24>":  "(emoji:饥饿)",
        "<emoji:25>":  "(emoji:困倦)",
        "<emoji:26>":  "(emoji:惊恐)",
        "<emoji:27>":  "(emoji:流汗)",
        "<emoji:28>":  "(emoji:憨笑)",
        "<emoji:29>":  "(emoji:绿盔)",
        "<emoji:30>":  "(emoji:奋斗)",
        "<emoji:31>":  "(emoji:咒骂)",
        "<emoji:32>":  "(emoji:疑问)",
        "<emoji:33>":  "(emoji:小声点)",
        "<emoji:34>":  "(emoji:晕了)",
        "<emoji:35>":  "(emoji:折磨)",
        "<emoji:36>":  "(emoji:衰)",
        "<emoji:37>":  "(emoji:骷髅)",
        "<emoji:38>":  "(emoji:敲打)",
        "<emoji:39>":  "(emoji:再见)",
        "<emoji:97>":  "(emoji:擦汗)",
        "<emoji:98>":  "(emoji:抠鼻子)",
        "<emoji:99>":  "(emoji:嘲讽的鼓掌)",
        "<emoji:100>": "(emoji:糗大了)",
        "<emoji:101>": "(emoji:坏笑)",
        "<emoji:102>": "(emoji:左哼哼)",
        "<emoji:103>": "(emoji:右哼哼)",
        "<emoji:104>": "(emoji:哈欠)",
        "<emoji:105>": "(emoji:鄙视)",
        "<emoji:106>": "(emoji:委屈)",
        "<emoji:107>": "(emoji:快哭了)",
        "<emoji:108>": "(emoji:阴险的笑)",
        "<emoji:305>": "(emoji:右亲亲)",
        "<emoji:109>": "(emoji:左亲亲)",
        "<emoji:110>": "(emoji:受惊)",
        "<emoji:111>": "(emoji:可怜)",
        "<emoji:172>": "(emoji:调皮地眨眼)",
        "<emoji:182>": "(emoji:笑哭)",
        "<emoji:179>": "(emoji:DOGE)",
        "<emoji:173>": "(emoji:泪奔)",
        "<emoji:174>": "(emoji:无奈)",
        "<emoji:212>": "(emoji:托腮)",
        "<emoji:175>": "(emoji:幸灾乐祸)",
        "<emoji:178>": "(emoji:奸笑)",
        "<emoji:177>": "(emoji:吐血)",
        "<emoji:176>": "(emoji:皱眉)",
        "<emoji:183>": "(emoji:我最美)",
        "<emoji:262>": "(emoji:脑阔疼)",
        "<emoji:263>": "(emoji:沧桑)",
        "<emoji:264>": "(emoji:捂脸)",
        "<emoji:265>": "(emoji:地铁老人手机)",
        "<emoji:266>": "(emoji:哦呦)",
        "<emoji:267>": "(emoji:头秃)",
        "<emoji:268>": "(emoji:黑人问号)",
        "<emoji:269>": "(emoji:暗中观察)",
        "<emoji:270>": "(emoji:emmm)",
        "<emoji:271>": "(emoji:吃瓜)",
        "<emoji:272>": "(emoji:呵呵哒)",
        "<emoji:277>": "(emoji:狗头)",
        "<emoji:307>": "(emoji:喵喵头)",
        "<emoji:306>": "(emoji:牛气冲天)",
        "<emoji:281>": "(emoji:翻白眼)",
        "<emoji:282>": "(emoji:敬礼salute)",
        "<emoji:283>": "(emoji:狂笑)",
        "<emoji:284>": "(emoji:面无表情)",
        "<emoji:285>": "(emoji:摸鱼)",
        "<emoji:293>": "(emoji:摸锦鲤)",
        "<emoji:286>": "(emoji:魔鬼笑)",
        "<emoji:287>": "(emoji:喝茶)",
        "<emoji:289>": "(emoji:让我康康)",
        "<emoji:294>": "(emoji:期待)",
        "<emoji:297>": "(emoji:拜谢)",
        "<emoji:298>": "(emoji:元宝)",
        "<emoji:299>": "(emoji:牛啊)",
        "<emoji:300>": "(emoji:胖三斤)",
        "<emoji:323>": "(emoji:痛苦面具)",
        "<emoji:332>": "(emoji:加油2023)",
        "<emoji:336>": "(emoji:豹富)",
        "<emoji:353>": "(emoji:拜托拜托)",
        "<emoji:355>": "(emoji:可爱捏)",
        "<emoji:356>": "(emoji:双击666)",
        "<emoji:354>": "(emoji:尊嘟假嘟)",
        "<emoji:352>": "(emoji:咦)",
        "<emoji:357>": "(emoji:我裂开了)",
        "<emoji:334>": "(emoji:虎虎生威)",
        "<emoji:347>": "(emoji:大展宏兔)",
        "<emoji:303>": "(emoji:右拜年)",
        "<emoji:302>": "(emoji:左拜年)",
        "<emoji:295>": "(emoji:抢红包)",
        "<emoji:49>":  "(emoji:拥抱)",
        "<emoji:66>":  "(emoji:爱心)",
        "<emoji:63>":  "(emoji:鲜花)",
        "<emoji:64>":  "(emoji:凋谢)",
        "<emoji:187>": "(emoji:幽灵)",
        "<emoji:146>": "(emoji:生气)",
        "<emoji:116>": "(emoji:烈焰红唇)",
        "<emoji:67>":  "(emoji:心碎)",
        "<emoji:60>":  "(emoji:咖啡)",
        "<emoji:185>": "(emoji:羊驼)",
        "<emoji:76>":  "(emoji:点赞)",
        "<emoji:124>": "(emoji:OK)",
        "<emoji:118>": "(emoji:抱拳)",
        "<emoji:78>":  "(emoji:握手)",
        "<emoji:119>": "(emoji:勾引)",
        "<emoji:79>":  "(emoji:胜利)",
        "<emoji:120>": "(emoji:拳头)",
        "<emoji:121>": "(emoji:差劲)",
        "<emoji:77>":  "(emoji:点踩)",
        "<emoji:123>": "(emoji:NO)",
        "<emoji:201>": "(emoji:熊熊点赞)",
        "<emoji:273>": "(emoji:我酸了)",
        "<emoji:46>":  "(emoji:猪头)",
        "<emoji:112>": "(emoji:菜刀)",
        "<emoji:56>":  "(emoji:大刀)",
        "<emoji:169>": "(emoji:左轮)",
        "<emoji:171>": "(emoji:豆汁)",
        "<emoji:59>":  "(emoji:粑粑)",
        "<emoji:144>": "(emoji:喝彩)",
        "<emoji:147>": "(emoji:棒棒糖)",
        "<emoji:89>":  "(emoji:西瓜)",
        "<emoji:41>":  "(emoji:呆坐)",
        "<emoji:125>": "(emoji:转圈)",
        "<emoji:42>":  "(emoji:爱情)",
        "<emoji:43>":  "(emoji:左右横跳)",
        "<emoji:86>":  "(emoji:怄火)",
        "<emoji:129>": "(emoji:告别)",
        "<emoji:85>":  "(emoji:飞吻)"};
      for(let emoji in emojiDic){
        EMJcontent = EMJcontent.replaceAll(emoji, emojiDic[emoji]);
      };
    };
    return EMJcontent;
  };// 依托答辩 怒水一伯五十行

};


module.exports = QQBot;